{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "function checkIfExist(arr: number[]): boolean {\n",
    "    let result = false\n",
    "    arr.forEach((v, i) => {\n",
    "        let d_v = v*2\n",
    "        let found = arr.findIndex((num)=>{return num===d_v})\n",
    "        if (found != -1 && found != i) {\n",
    "            result = true\n",
    "        }\n",
    "    })\n",
    "    return result;\n",
    "};"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "true\n"
     ]
    }
   ],
   "source": [
    "let arr = [10,2,5,3]\n",
    "checkIfExist(arr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/check-if-n-and-its-double-exist\n",
    "\n",
    "\n",
    "Runtime: 144 ms, faster than 7.14% of TypeScript online submissions for Check If N and Its Double Exist.\n",
    "Memory Usage: 40.3 MB, less than 71.43% of TypeScript online submissions for Check If N and Its Double Exist.\n",
    "\n",
    "\n",
    "\n",
    "```ts\n",
    "function checkIfExist(arr: number[]): boolean {\n",
    "    let result = false\n",
    "    arr.forEach((v, i) => {\n",
    "        let d_v = v*2\n",
    "        let found = arr.findIndex((num)=>{return num===d_v})\n",
    "        if (found != -1 && found != i) {\n",
    "            result = true\n",
    "        }\n",
    "    })\n",
    "    return result;\n",
    "};\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "TypeScript",
   "language": "typescript",
   "name": "tslab"
  },
  "language_info": {
   "codemirror_mode": {
    "mode": "typescript",
    "name": "javascript",
    "typescript": true
   },
   "file_extension": ".ts",
   "mimetype": "text/typescript",
   "name": "typescript",
   "version": "3.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
